package com.atguigui.leetcode;

/**
 * 1822.数组元素积的符号
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by WJX on 2022/10/27 8:55
 */
public class P1822SignOfTheProductOfAnArray {
    public static void main(String[] args) {
        Solution solution = new P1822SignOfTheProductOfAnArray().new Solution();
        // TO TEST
    }

    class Solution {
        public int arraySign(int[] nums) {

            int dp = 0;
            for (int num : nums) {
                if (num == 0) {
                    return 0;
                }
                if (num < 0) {
                    dp++;
                }
            }
            return dp % 2 == 0 ? 1 : -1;
        }
    }
}
